#ifndef _GWBASE_BASE_CONF_H_
#define _GWBASE_BASE_CONF_H_

#include <string>
#include <map>
#include <stdint.h>
#include <boost/shared_ptr.hpp>
#include "gwbase/base/status.h"

namespace dicom {

// INI config file
// # comment
// [section]
// key1 = value
class Conf {
 public:
  Conf(): valid_(false) { }
  ~Conf() { }

  bool valid() const { return valid_; }

  Status ParseFile(const std::string& path);
  Status ParseString(const std::string& data);

  int32_t GetInt32(const std::string& section, 
                   const std::string& key, 
                   int32_t default_value);

  int64_t GetInt64(const std::string& section, 
                   const std::string& key, 
                   int64_t default_value);

  double GetDouble(const std::string& section, 
                   const std::string& key, 
                   double default_value);
  std::string GetString(const std::string& section, 
                        const std::string& key, 
                        const std::string& default_value);

  bool GetBool(const std::string& section, 
               const std::string& key, 
               bool default_value);

  void AddInteger(const std::string& section,
                  const std::string& key, int value);
  void AddDouble(const std::string& section,
                 const std::string& key, double value);
  void AddString(const std::string& section,
                 const std::string& key, const std::string& value);

  void Dump(std::string* out);
 private:
  typedef std::map<std::string, std::string> KVMap;

  bool valid_;
  KVMap kvs_;
};

typedef boost::shared_ptr<Conf> ConfPtr;

};


#endif // _GWBASE_BASE_CONF_H_
